/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.blog.city.checkthedep.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Breath
 */
@Entity
@Table(name = "registered_user", catalog = "citypress", uniqueConstraints = {@UniqueConstraint(columnNames = {"email"}),@UniqueConstraint(columnNames = {"username"})})
@TableGenerator(name = "REG_SEQ",
table = "SEQUENCE_TABLE",
pkColumnName = "SEQUENCE_NAME",
valueColumnName = "SEQUENCE_COUNT",
pkColumnValue="REG_SEQ")
@NamedQueries({
    @NamedQuery(name = "RegisteredUser.findAll", query = "SELECT r FROM RegisteredUser r"),
    @NamedQuery(name = "RegisteredUser.findById", query = "SELECT r FROM RegisteredUser r WHERE r.id = :id"),
    @NamedQuery(name = "RegisteredUser.findByUsername", query = "SELECT r FROM RegisteredUser r WHERE r.username = :username"),
    @NamedQuery(name = "RegisteredUser.findByStreetName", query = "SELECT r FROM RegisteredUser r WHERE r.streetName = :streetName"),
    @NamedQuery(name = "RegisteredUser.findByPassword", query = "SELECT r FROM RegisteredUser r WHERE r.password = :password"),
    @NamedQuery(name = "RegisteredUser.findByZip", query = "SELECT r FROM RegisteredUser r WHERE r.zip = :zip"),
    @NamedQuery(name = "RegisteredUser.findBySurname", query = "SELECT r FROM RegisteredUser r WHERE r.surname = :surname"),
    @NamedQuery(name = "RegisteredUser.findByUserType", query = "SELECT r FROM RegisteredUser r WHERE r.userType = :userType"),
    @NamedQuery(name = "RegisteredUser.findByEmail", query = "SELECT r FROM RegisteredUser r WHERE r.email = :email"),
    @NamedQuery(name = "RegisteredUser.findByName", query = "SELECT r FROM RegisteredUser r WHERE r.name = :name"),
    @NamedQuery(name = "RegisteredUser.findByWebsite", query = "SELECT r FROM RegisteredUser r WHERE r.website = :website")})
public class RegisteredUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "REG_SEQ")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "username")
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "streetName")
    private String streetName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "password")
    private String password;
    @Basic(optional = false)
    @NotNull
    @Column(name = "zip")
    private int zip;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "surname")
    private String surname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "userType")
    private String userType;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "name")
    private String name;
    @Size(max = 150)
    @Column(name = "website")
    private String website;
    @OneToMany(mappedBy = "registeredUserId")
    private List<Article> articleList;
    @OneToMany(mappedBy = "registeredUserId")
    private List<Comment> commentList;

    /**
     * 
     */
    public RegisteredUser() {
    }

    /**
     * 
     * @param id
     */
    public RegisteredUser(Integer id) {
        this.id = id;
    }

    /**
     * 
     * @param id
     * @param username
     * @param streetName
     * @param password
     * @param zip
     * @param surname
     * @param userType
     * @param email
     * @param name
     */
    public RegisteredUser(Integer id, String username, String streetName, String password, int zip, String surname, String userType, String email, String name) {
        this.id = id;
        this.username = username;
        this.streetName = streetName;
        this.password = password;
        this.zip = zip;
        this.surname = surname;
        this.userType = userType;
        this.email = email;
        this.name = name;
    }

    /**
     * 
     * @return
     */
    public Integer getId() {
        return id;
    }

    /**
     * 
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * 
     * @return
     */
    public String getUsername() {
        return username;
    }

    /**
     * 
     * @param username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * 
     * @return
     */
    public String getStreetName() {
        return streetName;
    }

    /**
     * 
     * @param streetName
     */
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }

    /**
     * 
     * @return
     */
    public String getPassword() {
        return password;
    }

    /**
     * 
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 
     * @return
     */
    public int getZip() {
        return zip;
    }

    /**
     * 
     * @param zip
     */
    public void setZip(int zip) {
        this.zip = zip;
    }

    /**
     * 
     * @return
     */
    public String getSurname() {
        return surname;
    }

    /**
     * 
     * @param surname
     */
    public void setSurname(String surname) {
        this.surname = surname;
    }

    /**
     * 
     * @return
     */
    public String getUserType() {
        return userType;
    }

    /**
     * 
     * @param userType
     */
    public void setUserType(String userType) {
        this.userType = userType;
    }

    /**
     * 
     * @return
     */
    public String getEmail() {
        return email;
    }

    /**
     * 
     * @param email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * 
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * 
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 
     * @return
     */
    public String getWebsite() {
        return website;
    }

    /**
     * 
     * @param website
     */
    public void setWebsite(String website) {
        this.website = website;
    }

    /**
     * 
     * @return
     */
    @XmlTransient
    public List<Article> getArticleList() {
        return articleList;
    }

    /**
     * 
     * @param articleList
     */
    public void setArticleList(List<Article> articleList) {
        this.articleList = articleList;
    }

    /**
     * 
     * @return
     */
    @XmlTransient
    public List<Comment> getCommentList() {
        return commentList;
    }

    /**
     * 
     * @param commentList
     */
    public void setCommentList(List<Comment> commentList) {
        this.commentList = commentList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RegisteredUser)) {
            return false;
        }
        RegisteredUser other = (RegisteredUser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.blog.city.checkthedep.entities.RegisteredUser[ id=" + id + " ]";
    }
    
}
